<?php

use Faker\Factory as Faker;
use App\Models\IntegralLog;
use App\Repositories\IntegralLogRepository;

trait MakeIntegralLogTrait
{
    /**
     * Create fake instance of IntegralLog and save it in database
     *
     * @param array $integralLogFields
     * @return IntegralLog
     */
    public function makeIntegralLog($integralLogFields = [])
    {
        /** @var IntegralLogRepository $integralLogRepo */
        $integralLogRepo = App::make(IntegralLogRepository::class);
        $theme = $this->fakeIntegralLogData($integralLogFields);
        return $integralLogRepo->create($theme);
    }

    /**
     * Get fake instance of IntegralLog
     *
     * @param array $integralLogFields
     * @return IntegralLog
     */
    public function fakeIntegralLog($integralLogFields = [])
    {
        return new IntegralLog($this->fakeIntegralLogData($integralLogFields));
    }

    /**
     * Get fake data of IntegralLog
     *
     * @param array $postFields
     * @return array
     */
    public function fakeIntegralLogData($integralLogFields = [])
    {
        $fake = Faker::create();

        return array_merge([
            'user_id' => $fake->randomDigitNotNull,
            'type' => $fake->randomDigitNotNull,
            'add_type' => $fake->randomDigitNotNull,
            'junior_id' => $fake->randomDigitNotNull,
            'title' => $fake->word,
            'amount' => $fake->randomDigitNotNull,
            'calculate' => $fake->randomDigitNotNull,
            'created_at' => $fake->word,
            'updated_at' => $fake->word
        ], $integralLogFields);
    }
}
